import request from '@/config/axios'

// 广告位 VO
export interface AdvPositionVO {
  id: number // 广告位ID
  title: string // 广告位名称
  type: number // 广告位类型（1渝快办）
  status: number // 状态（0正常 1关闭）
}

// 广告位 API
export const AdvPositionApi = {
  // 查询广告位分页
  getAdvPositionPage: async (params: any) => {
    return await request.get({ url: `/cms/adv-position/page`, params })
  },

  // 查询广告位详情
  getAdvPosition: async (id: number) => {
    return await request.get({ url: `/cms/adv-position/get?id=` + id })
  },

  // 新增广告位
  createAdvPosition: async (data: AdvPositionVO) => {
    return await request.post({ url: `/cms/adv-position/create`, data })
  },

  // 修改广告位
  updateAdvPosition: async (data: AdvPositionVO) => {
    return await request.put({ url: `/cms/adv-position/update`, data })
  },

  // 删除广告位
  deleteAdvPosition: async (id: number) => {
    return await request.delete({ url: `/cms/adv-position/delete?id=` + id })
  },

  // 导出广告位 Excel
  exportAdvPosition: async (params) => {
    return await request.download({ url: `/cms/adv-position/export-excel`, params })
  },

// ==================== 子表（广告） ====================

  // 获得广告分页
  getAdvAdvPage: async (params) => {
    return await request.get({ url: `/cms/adv-position/adv-adv/page`, params })
  },
  // 新增广告
  createAdvAdv: async (data) => {
    return await request.post({ url: `/cms/adv-position/adv-adv/create`, data })
  },

  // 修改广告
  updateAdvAdv: async (data) => {
    return await request.put({ url: `/cms/adv-position/adv-adv/update`, data })
  },

  // 删除广告
  deleteAdvAdv: async (id: number) => {
    return await request.delete({ url: `/cms/adv-position/adv-adv/delete?id=` + id })
  },

  // 获得广告
  getAdvAdv: async (id: number) => {
    return await request.get({ url: `/cms/adv-position/adv-adv/get?id=` + id })
  }
}